//
//  CommonListCell.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/25.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "CommonListCell.h"

@interface CommonListCell()
@property(nonatomic,strong)UILabel *itemTypes;
@property(nonatomic,strong)UILabel *itemTypesLabel;
@property(nonatomic,strong)UILabel *memberName;
@property(nonatomic,strong)UILabel *memberNameLabel;
@property(nonatomic,strong)UILabel *source;
@property(nonatomic,strong)UILabel *sourceLabel;
@property(nonatomic,strong)UILabel *createDate;
@property(nonatomic,strong)UILabel *createDateLabel;
@property(nonatomic,strong)UILabel *NoLabel;
@property(nonatomic,strong)UILabel *totalMoney;
@property(nonatomic,strong)UILabel *totalMoneyLabel;

@property(nonatomic,strong)UILabel *depositLabel;

@property(nonatomic,strong)UILabel *lineLabel;
@property(nonatomic,strong)UILabel *state1;
@property(nonatomic,strong)UILabel *state2;
@property(nonatomic,strong)UILabel *state3;
@end
@implementation CommonListCell

- (void)awakeFromNib {

}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createView];
        [self setViewAutoLayout];
    }
    return self;
}
-(void)createView
{
    self.backgroundColor=[UIColor whiteColor];
    self.NoLabel=[[UILabel alloc] init];
    self.NoLabel.font= [UIFont systemFontOfSize:17];
    self.NoLabel.textColor=[UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1.0];
    [self addSubview:self.NoLabel];
    self.state1=[[UILabel alloc] init];
    self.state1.font= [UIFont systemFontOfSize:13];
    [self addSubview:self.state1];
    self.state2=[[UILabel alloc] init];
    self.state2.font= [UIFont systemFontOfSize:13];
    [self addSubview:self.state2];
    self.state3=[[UILabel alloc] init];
    self.state3.font= [UIFont systemFontOfSize:13];
    [self addSubview:self.state3];
    self.memberName=[[UILabel alloc] init];
    self.memberName.font= [UIFont systemFontOfSize:14];
    self.memberName.text=@"会员";
    self.memberName.textColor=zhonghuiColor;
    [self addSubview:self.memberName];
    self.memberNameLabel=[[UILabel alloc] init];
    self.memberNameLabel.font= [UIFont systemFontOfSize:14];
    self.memberNameLabel.textColor=shenhuiColor;
    [self addSubview:self.memberNameLabel];
    self.source=[[UILabel alloc] init];
    self.source.font= [UIFont systemFontOfSize:14];
    self.source.text=@"来源";
    self.source.textColor=zhonghuiColor;
    [self addSubview:self.source];
    self.sourceLabel=[[UILabel alloc] init];
    self.sourceLabel.font= [UIFont systemFontOfSize:14];
    self.sourceLabel.textColor=shenhuiColor;
    [self addSubview:self.sourceLabel];
    self.createDate=[[UILabel alloc] init];
    self.createDate.font= [UIFont systemFontOfSize:14];
    self.createDate.text=@"登记日期";
    self.createDate.textColor=zhonghuiColor;
    [self addSubview:self.createDate];
    self.createDateLabel=[[UILabel alloc] init];
    self.createDateLabel.font= [UIFont systemFontOfSize:14];
    self.createDateLabel.textColor=shenhuiColor;
    [self addSubview:self.createDateLabel];
    self.itemTypes=[[UILabel alloc] init];
    self.itemTypes.font= [UIFont systemFontOfSize:14];
    self.itemTypes.textColor=zhonghuiColor;
    [self addSubview:self.itemTypes];
    self.itemTypesLabel=[[UILabel alloc] init];
    self.itemTypesLabel.font= [UIFont systemFontOfSize:14];
    self.itemTypesLabel.textColor=shenhuiColor;
    [self addSubview:self.itemTypesLabel];
    self.totalMoney=[[UILabel alloc] init];
    self.totalMoney.font= [UIFont systemFontOfSize:14];
    self.totalMoney.text=@"金额 ¥";
    self.totalMoney.textColor=zhonghuiColor;
    [self addSubview:self.totalMoney];
    self.totalMoneyLabel=[[UILabel alloc] init];
    self.totalMoneyLabel.font= [UIFont systemFontOfSize:14];
    self.totalMoneyLabel.textColor=shenhuiColor;
    [self addSubview:self.totalMoneyLabel];
   
    self.depositLabel=[[UILabel alloc] init];
    self.depositLabel.font= [UIFont systemFontOfSize:14];
    self.depositLabel.textColor=shenhuiColor;
    [self addSubview:self.depositLabel];
    
    self.lineLabel=[[UILabel alloc] init];
    [self.lineLabel setBackgroundColor:[UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
    self.lineLabel.textColor=[UIColor clearColor];
    [self addSubview:self.lineLabel];
}
-(void)setModel:(OrderListModel *)model{
    if ([model.orderStatus  isEqualToString:@"N"]) {
        self.state1.textColor=shenhongseColor;
        self.state1.text=[NSString stringWithFormat:@"%@",  @"未收款"];
    }if ([model.orderStatus isEqualToString:@"Y"]) {
        self.state1.textColor=luseColor;
        self.state1.text=[NSString stringWithFormat:@"%@",  @"收全款"];
    }
    if ([model.orderStatus isEqualToString:@"P"]) {
        self.state1.textColor=luseColor;
        self.state1.text=[NSString stringWithFormat:@"%@",  @"收定金"];
    }
    if ([model.orderStatus isEqualToString:@"C"]) {
        self.state1.textColor=luseColor;
        self.state1.text=[NSString stringWithFormat:@"%@",  @" 已取消"];
    }
    if ([model.deliveryStatus  isEqualToString:@"N"]) {
        self.state2.textColor=shenhongseColor;
        self.state2.text=[NSString stringWithFormat:@"%@",  @"未配送"];
    }if ([model.deliveryStatus isEqualToString:@"Y"]) {
        self.state2.textColor=luseColor;
        self.state2.text=[NSString stringWithFormat:@"%@",  @"已配送"];
    }
    if ([model.deliveryStatus isEqualToString:@"B"]) {
        self.state2.textColor=luseColor;
        self.state2.text=[NSString stringWithFormat:@"%@",  @"部分配送"];
    }
    if ([model.deliveryStatus isEqualToString:@"X"]) {
        self.state2.textColor=luseColor;
        self.state2.text=[NSString stringWithFormat:@"%@",  @"无需配送"];
        
    }

    self.NoLabel.text=[NSString stringWithFormat:@"%@",  model.orderNo];
    self.lineLabel.text=[NSString stringWithFormat:@"%@",model.orderNo];
    self.memberNameLabel.text=[NSString stringWithFormat:@"%@",model.memberName];
    self.sourceLabel.text=[NSString stringWithFormat:@"%@",model.source];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",model.totalMoney];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    self.totalMoneyLabel.text=[NSString stringWithFormat:@"%@",formattedNumberString];
    NSRange range={0,10};
    NSString* string =[model.orderDate substringWithRange:range];
    self.createDateLabel.text=[NSString stringWithFormat:@"%@",string];
    self.itemTypes.text=@"购买";
    self.itemTypesLabel.text=[NSString stringWithFormat:@"%@ 共%@件",model.itemTypes,model.totalQuantity];
    if ([[NSString stringWithFormat:@"%@",model.orderStatus ] isEqualToString:@"P"]) {
        
        NSString*GoldPrice1=[NSString stringWithFormat:@"%@",model.earnestMoney];
        NSNumberFormatter *numberFormatter1 = [[NSNumberFormatter alloc] init];
        [numberFormatter1 setPositiveFormat:@"###,##0.00;"];
        NSString *formattedNumberString1 = [numberFormatter1 stringFromNumber:[NSNumber numberWithDouble:GoldPrice1.floatValue]];
        self.depositLabel.text=[NSString stringWithFormat:@"已收定金 ￥%@",formattedNumberString1];
        self.depositLabel.textColor=[UIColor blackColor];

        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已收定金 ￥%@",formattedNumberString1]];
        
        [AttributedStr addAttribute:NSFontAttributeName
         
                              value:[UIFont systemFontOfSize:contenfot]
         
                              range:NSMakeRange(0, 6)];
        
        [AttributedStr addAttribute:NSForegroundColorAttributeName
         
                              value:shenhuiColor
         
                              range:NSMakeRange(0, 6)];
        
        
        self.depositLabel.attributedText = AttributedStr;
        
    }

}

//-(void)setServiceModel:(ServiceListModel *)ServiceModel{
//    
//    if ([ServiceModel.serviceStatus  isEqualToString:@"A"]) {
//       self.state1.textColor=luseColor;
//        self.state1.text=[NSString stringWithFormat:@"%@",  @"服务申请"];
//    }if ([ServiceModel.serviceStatus isEqualToString:@"R"]) {
//        self.state1.textColor=luseColor;
//        self.state1.text=[NSString stringWithFormat:@"%@",  @"服务登记"];
//    }
//    if ([ServiceModel.serviceStatus isEqualToString:@"C"]) {
//        self.state1.textColor=luseColor;
//        self.state1.text=[NSString stringWithFormat:@"%@",  @"服务确认"];
//    }
//    if ([ServiceModel.serviceStatus isEqualToString:@"N"]) {
//       self.state1.textColor=qianhuiColor;
//       self.state1.text=[NSString stringWithFormat:@"%@",  @"已取消"];
//    }
//  
//    self.state2.textColor=hongseColor;
//    self.state2.text=[NSString stringWithFormat:@"%@",  ServiceModel.serviceTypeName];
//    self.NoLabel.text=[NSString stringWithFormat:@"%@", ServiceModel.serviceNo];
//    self.lineLabel.text=[NSString stringWithFormat:@"%@",ServiceModel.serviceNo];
//    self.memberNameLabel.text=[NSString stringWithFormat:@"%@",ServiceModel.memberName];
//    self.sourceLabel.text=[NSString stringWithFormat:@"%@",ServiceModel.source];
//    NSString*GoldPrice=[NSString stringWithFormat:@"%@",ServiceModel.totalMoney];
//    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
//    [numberFormatter setPositiveFormat:@"###,##0.00;"];
//    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
//    self.totalMoneyLabel.text=[NSString stringWithFormat:@"%@",formattedNumberString];
//    NSRange range={0,10};
//    NSString* string =[ServiceModel.serviceDate substringWithRange:range];
//    self.createDateLabel.text=[NSString stringWithFormat:@"%@",string];
//    self.itemTypes.text=@"服务";
//    self.itemTypesLabel.text=[NSString stringWithFormat:@"%@ 共%@件",ServiceModel.itemTypes,ServiceModel.totalQuantity];
//    
//}
-(void)setDeliveryModel:(DeliveryListModel *)DeliveryModel{
    
    if ([DeliveryModel.deliveryStatus isEqualToString:@"Y"]) {
        self.state1.textColor=luseColor;
        self.state1.text=[NSString stringWithFormat:@"%@",  @"已配送"];
    }
    if ([DeliveryModel.deliveryStatus isEqualToString:@"N"]) {
        self.state1.textColor=hongseColor;
        self.state1.text=[NSString stringWithFormat:@"%@",  @"未配送"];
    }

    self.NoLabel.text=[NSString stringWithFormat:@"%@", DeliveryModel.deliveryNo];
    self.lineLabel.text=[NSString stringWithFormat:@"%@",DeliveryModel.deliveryNo];
    self.memberNameLabel.text=[NSString stringWithFormat:@"%@",DeliveryModel.memberName];
    self.sourceLabel.text=[NSString stringWithFormat:@"%@",DeliveryModel.source];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",DeliveryModel.totalMoney];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    self.totalMoneyLabel.text=[NSString stringWithFormat:@"%@",formattedNumberString];
    NSRange range={0,10};
    NSString* string =[DeliveryModel.deliveryDate substringWithRange:range];
    self.createDateLabel.text=[NSString stringWithFormat:@"%@",string];
    self.itemTypes.text=@"购买";
    self.itemTypesLabel.text=[NSString stringWithFormat:@"%@ 共%@件",DeliveryModel.itemTypes,DeliveryModel.totalQuantity];
    
}
-(void)setWhsOutListModel:(WhsOutListModel *)WhsOutListModel{

    self.state1.textColor=luseColor;
    self.state1.text=[NSString stringWithFormat:@"%@",  WhsOutListModel.whsOutStatusName];
    self.NoLabel.text=[NSString stringWithFormat:@"%@", WhsOutListModel.whsOutNo];
    self.lineLabel.text=[NSString stringWithFormat:@"%@",WhsOutListModel.whsOutNo];
    self.memberName.text=[NSString stringWithFormat:@"%@",@"员工"];
    self.memberNameLabel.text=[NSString stringWithFormat:@"%@",WhsOutListModel.createName];
    self.source.text=[NSString stringWithFormat:@"%@",@"仓库"];
    self.sourceLabel.text=[NSString stringWithFormat:@"%@",WhsOutListModel.whsName];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",WhsOutListModel.totalMoney];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    self.totalMoneyLabel.text=[NSString stringWithFormat:@"%@",formattedNumberString];
    NSRange range={0,10};
    NSString* string =[WhsOutListModel.whsOutDate substringWithRange:range];
    self.createDateLabel.text=[NSString stringWithFormat:@"%@",string];
    self.itemTypes.text=@"出库商品";
    self.itemTypesLabel.text=[NSString stringWithFormat:@"%@ 共%@件",WhsOutListModel.itemTypes,WhsOutListModel.totalQuantity];

}

-(void)setWhsInListModel:(WhsInListModel *)WhsInListModel{

    self.state1.textColor=luseColor;
    self.state1.text=[NSString stringWithFormat:@"%@",  WhsInListModel.whsInStatusName];
    self.NoLabel.text=[NSString stringWithFormat:@"%@", WhsInListModel.whsInNo];
    self.lineLabel.text=[NSString stringWithFormat:@"%@",WhsInListModel.whsInNo];
    self.memberName.text=[NSString stringWithFormat:@"%@",@"员工"];
    self.memberNameLabel.text=[NSString stringWithFormat:@"%@",WhsInListModel.createName];
    self.source.text=[NSString stringWithFormat:@"%@",@"仓库"];
    self.sourceLabel.text=[NSString stringWithFormat:@"%@",WhsInListModel.whsName];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",WhsInListModel.totalMoney];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    self.totalMoneyLabel.text=[NSString stringWithFormat:@"%@",formattedNumberString];
    NSRange range={0,10};
    NSString* string =[WhsInListModel.whsInDate substringWithRange:range];
    self.createDateLabel.text=[NSString stringWithFormat:@"%@",string];
    self.itemTypes.text=@"入库商品";
    self.itemTypesLabel.text=[NSString stringWithFormat:@"%@ 共%@件",WhsInListModel.itemTypes,WhsInListModel.totalQuantity];
}
-(void)setCheckVouchListModel:(CheckVouchListModel *)CheckVouchListModel{

    self.state1.textColor=luseColor;
    self.state1.text=[NSString stringWithFormat:@"%@",  CheckVouchListModel.ckvStatus];
    self.NoLabel.text=[NSString stringWithFormat:@"%@", CheckVouchListModel.ckvNo];
    self.lineLabel.text=[NSString stringWithFormat:@"%@",CheckVouchListModel.ckvNo];
    self.memberName.text=[NSString stringWithFormat:@"%@",@"员工"];
    self.memberNameLabel.text=[NSString stringWithFormat:@"%@",CheckVouchListModel.userName];
    self.source.text=[NSString stringWithFormat:@"%@",@"仓库"];
    self.sourceLabel.text=[NSString stringWithFormat:@"%@",CheckVouchListModel.whsName];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",CheckVouchListModel.totalMoney];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    self.totalMoneyLabel.text=[NSString stringWithFormat:@"%@",formattedNumberString];
    NSRange range={0,10};
    NSString* string =[CheckVouchListModel.createDate substringWithRange:range];
    self.createDateLabel.text=[NSString stringWithFormat:@"%@",string];
    self.itemTypes.text=@"盘点商品";
    self.itemTypesLabel.text=[NSString stringWithFormat:@"%@ 共%@件",CheckVouchListModel.itemTypeName,CheckVouchListModel.totalQuantity];


}
-(void)setViewAutoLayout
{
    [self.NoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@17);
        make.top.equalTo(self.mas_top).with.offset(25);
    }];
    
    [self.state1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.NoLabel.mas_right).with.offset(15);
        make.height.equalTo(@13);
        
         make.centerY.equalTo(self.NoLabel.mas_centerY) ;
    }];
    [self.state2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.state1.mas_right).with.offset(5);
        make.height.equalTo(@13);
        
        make.centerY.equalTo(self.NoLabel.mas_centerY) ;
    }];
    [self.state3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.state2.mas_right).with.offset(5);
        make.height.equalTo(@13);
        
        make.centerY.equalTo(self.NoLabel.mas_centerY) ;
    }];
    [self.memberName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@14);
        make.top.equalTo(self.NoLabel.mas_bottom).with.offset(15);
    }];
    
    [self.memberNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.memberName.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.memberName.mas_centerY) ;
        
    }];
    
    
    [self.source mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.memberNameLabel.mas_right).with.offset(15) ;
        make.height.equalTo(@14);
       make.centerY.equalTo(self.memberName.mas_centerY) ;
    }];
    
    [self.sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.source.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
       make.centerY.equalTo(self.memberName.mas_centerY) ;
        
    }];
    [self.createDate mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.sourceLabel.mas_right).with.offset(15);
        
        make.height.equalTo(@14);
        
      make.centerY.equalTo(self.memberName.mas_centerY) ;
    }];
    
    [self.createDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.createDate.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.memberName.mas_centerY) ;
        
    }];
    
    
    [self.itemTypes mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@14);
        make.top.equalTo(self.memberName.mas_bottom).with.offset(5);
    }];
    
    [self.itemTypesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.itemTypes.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.itemTypes.mas_centerY) ;
        
    }];
    [self.totalMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.itemTypesLabel.mas_right).with.offset(15) ;
        make.height.equalTo(@14);
        make.centerY.equalTo(self.itemTypes.mas_centerY) ;

    }];
    
    [self.totalMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.totalMoney.mas_right).with.offset(3);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.itemTypes.mas_centerY) ;
        
    }];
    [self.depositLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.totalMoneyLabel.mas_right).with.offset(15);
        make.height.equalTo(@14);
        
        make.centerY.equalTo(self.itemTypes.mas_centerY) ;
        
    }];
    
    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(10);
        make.right.equalTo(self.mas_right).with.offset(-10) ;
        
        make.height.equalTo(@1);
        
        make.top.equalTo(@108).with.offset(0);
    }];
    
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
